<template>
    <div id="app">
        <router-view />
         
        <!-- 返回顶部 -->
        <goTop></goTop>
    </div>
</template>


<script>
    import goTop from '@/components/GoTop'
    import themeMixin from '@/mixin/theme'
    export default {
        name: 'App',
        mixins: [themeMixin],
        components: {
            goTop
        },
        created(){
            
            // 渲染主题颜色
            if (localStorage.getItem('CM-Admin-setting')) {
                let settingStr = localStorage.getItem( "CM-Admin-setting" )
                let val = JSON.parse( settingStr ).value;
                this.$store.dispatch('settings/changeSetting', {
                    key: 'theme',
                    value: val
                })
                this.updateTheme(val)
            }else{
                this.$store.dispatch('settings/changeSetting', {
                    key: 'theme',
                    value: this.$store.state.settings.theme
                })
                this.updateTheme(this.$store.state.settings.theme)
            }

            // 渲染布局
            if (localStorage.getItem('CM-Admin-setting-layout')) {
                let settingStr = localStorage.getItem( "CM-Admin-setting-layout" )
                let val = JSON.parse( settingStr ).value;
                this.$store.dispatch('settings/changeSetting', {
                    key: 'layout',
                    value: val
                })
            }else{
                this.$store.dispatch('settings/changeSetting', {
                    key: 'layout',
                    value: this.$store.state.settings.layout
                })
            }
            




        }
    }
</script>

